//
//  main.cpp
//  c++practice
//
//  Created by mac on 2020/3/29.
//  Copyright © 2020 DDI. All rights reserved.
//

//#include <iostream>
//#include<bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
//#include<bits/stdc++.h>
using namespace std;
 
int n;
int s[9], tag[9]={0};
 
void H(int start)
{
    for ( int i=start ; i < n ; i++ )
    {
        if ( i>start && s[i]==s[i-1] ) continue; //相同就跳过，相当于剪枝
        tag[i] = 1;
        for ( int j=0 ; j < n ; j++ ) if ( tag[j] ) printf("%d ", s[j]);
        printf("\n");
        H(i+1);
        tag[i] = 0;
    }
}
 
int main()
{
    while ( ~scanf("%d", &n) )
    {
        for ( int i=0 ; i < n ; i++ ) scanf("%d", &s[i]);
        sort(s, s+n);
        printf("\n");
        H(0);
    }
     
    return 0;
} 
